package com.zhoug.zmui.group;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;

import com.zhoug.zmui.utils.MaxViewSizeHelper;

import androidx.annotation.Nullable;

/**
 * 限制最大高度
 * @Author 35574
 * @Date 2020/7/21
 * @Description
 */
public class ZMUILineaLayout extends LinearLayout {
    private MaxViewSizeHelper mMaxViewSizeHelper;

    public ZMUILineaLayout(Context context) {
        this(context, null);
    }

    public ZMUILineaLayout(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public ZMUILineaLayout(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        mMaxViewSizeHelper = new MaxViewSizeHelper(context, attrs, defStyleAttr);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure( mMaxViewSizeHelper.getWidthMeasureSpec(widthMeasureSpec), mMaxViewSizeHelper.getHeightMeasureSpec(heightMeasureSpec));
    }

    public void setMaxHeight(int maxHeight) {
        mMaxViewSizeHelper.setMaxHeight(maxHeight);
    }

    public int getMaxHeight() {
        return mMaxViewSizeHelper.getMaxHeight();
    }

    public int getMaxWidth() {
        return mMaxViewSizeHelper.getMaxWidth();
    }

    public void setMaxWidth(int maxWidth) {
        mMaxViewSizeHelper.setMaxWidth(maxWidth);
    }

}
